package com.qingneng.probiz.web;

import java.util.List;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.Action;
import com.qingneng.probiz.service.sdk.IClientInfoService;
import com.qingneng.probiz.vo.ProClientInfo;
import com.tbfs.common.BaseAction;
import com.tbfs.util.PaginationBean;

@SuppressWarnings({"serial","rawtypes"})
public class LoadClientInfoAction extends BaseAction{
	// 日志相关
	private static final Logger logger = Logger
	.getLogger(LoadClientInfoAction.class);
	
	// init service
	public IClientInfoService clientInfoService;

	// 构造函数
	public LoadClientInfoAction(IClientInfoService clientInfoService) {
		this.clientInfoService = clientInfoService;
	}
    
	public LoadClientInfoAction() {

	}
	
	private List rows = null;

	private Integer total;

	private ProClientInfo clientInfo=new ProClientInfo();

	private String message;

	private String volidateAccessDataAuth;

	public List getRows() {
		return rows;
	}

	public void setRows(List rows) {
		this.rows = rows;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public ProClientInfo getClientInfo() {
		return clientInfo;
	}

	public void setClientInfo(ProClientInfo clientInfo) {
		this.clientInfo = clientInfo;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getVolidateAccessDataAuth() {
		return volidateAccessDataAuth;
	}

	public void setVolidateAccessDataAuth(String volidateAccessDataAuth) {
		this.volidateAccessDataAuth = volidateAccessDataAuth;
	}
	
	/**
	 * 查询客户信息
	 * @return
	 */
	public String loadData() {
		try {
			logger.info(" loadData() loadClientInfoAction start  ");
			//初始化查询对象
			if(clientInfo==null){
				clientInfo = new ProClientInfo();
			}
			//分页
			this.processPaginationBean();
			PaginationBean page=this.getPaginationBean();
			volidateAccessDataAuth = this.volidateAccessDataAuth();
			//所有数据
			if("0".equals(volidateAccessDataAuth)){
				
			}
			int limit=page.getPageSize()*page.getPageNo()-1;
			int start=page.getStartIndex();
			clientInfo.setLimit(limit);
			clientInfo.setStart(start);
			rows  =  clientInfoService.getClientInfoList(clientInfo);
			total = clientInfoService.getClientInfoTotalRows(clientInfo);
			
		} catch (Exception e) {
			e.printStackTrace();
			logger.info(" loadData() loadClientInfoAction error:"+e.getMessage());
		}
		
		logger.info(" loadData() loadClientInfoAction end  ");
		return Action.SUCCESS;
	}

}
